package net.siufung.boot.caffeine.properties;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;
import java.util.List;


/**
 * 缓存配置
 * @author 陈建峰
 * @since 2022/2/9 11:10 下午
 */
@Getter
@Setter
@ConfigurationProperties(prefix = CaffeineProperties.CAFFEINE_PREFIX)
@ApiModel("Caffine缓存实体")
public class CaffeineProperties {
	
	public static final String CAFFEINE_PREFIX = "cache.caffeine";

    @ApiModelProperty("是否启用")
	private Boolean enabled = false;
//	@ApiModelProperty("缓存名称集合")
//	private List<String> cacheName;
//	@ApiModelProperty("缓存配置")
//	private String spec;
//	private Integer initialCapacity;
//    private Long maximumSize;
//  	private Long maximumWeight;
//    private String weakKeys;
//    private String weakValues;
//    private String softValues;
//  	private Duration expireAfterAccess;
//    private Duration expireAfterWrite;
//    private Duration refreshAfterWrite;
	@ApiModelProperty("自定义缓存")
    private List<Config> configs;

    @Getter
    @Setter
    @ApiModel("自定义Caffine缓存实体")
    public static class Config {
    	@ApiModelProperty("缓存名称集合")
        private List<String> cacheName;
    	@ApiModelProperty("缓存配置")
        private String spec;
    	private Integer initialCapacity;
        private Long maximumSize;
      	private Long maximumWeight;
        private String weakKeys;
        private String weakValues;
        private String softValues;
      	private Duration expireAfterAccess;
        private Duration expireAfterWrite;
        private Duration refreshAfterWrite;
    }
	
}
